package com.sanjiahantang.ythshopping.presenter;

import android.content.Context;
import android.util.Log;

import com.sanjiahantang.ythshopping.config.ConfigValue;
import com.sanjiahantang.ythshopping.http.BaseDelegate;
import com.sanjiahantang.ythshopping.http.OkHttpClientManager;
import com.sanjiahantang.ythshopping.model.AliPatModel;
import com.sanjiahantang.ythshopping.model.WXpayModel;
import com.sanjiahantang.ythshopping.views.OrderPopPayView;
import com.squareup.okhttp.Request;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by admin on 2017/8/15.
 */

public class OrderPopPayPresenter extends BasePresenter  {

    Context context;
    Map<String ,String> params=new HashMap();
    OrderPopPayView view;

    public OrderPopPayPresenter(Context context,OrderPopPayView view,String orderid)
    {

        this.view=view;
        params.put("key", ConfigValue.DATA_KEY);
        params.put("order_id",orderid);

        this.context=context;
    }



    public void LoadALiPayMsg( String payset, String payid){
        params.put("pay_set",payset);
        params.put("pay_id",payid);
        OkHttpClientManager.postAsyn(context, ConfigValue.APP_IP + "order/editPayment", params, new BaseDelegate.ResultCallback<AliPatModel>() {
            @Override
            public void onError(Request request, Object tag, Exception e) {
                Log.e("LoadALiPayMsg","fail:" + e.getMessage());
            }

            @Override
            public void onResponse(AliPatModel response, Object tag) {
                view.reALiinfo(response);
            }


        });
    }

    public void LoadWXPayMsg( String payset, String payid){
        params.put("pay_set",payset);
        params.put("pay_id",payid);
        OkHttpClientManager.postAsyn(context, ConfigValue.APP_IP + "order/editPayment", params, new BaseDelegate.ResultCallback<WXpayModel>() {
            @Override
            public void onError(Request request, Object tag, Exception e) {
                Log.e("LoadALiPayMsg","fail:" + e.getMessage());
            }

            @Override
            public void onResponse(WXpayModel response, Object tag) {
                view.reWXinfo(response);
            }


        });
    }



}
